fullDiscountCoupon.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  1. <template>
  2. <div class="fullDiscountCoupon app-container">
  3. <el-form
  4. :model="setQuery"
  5. ref="setQuery"
  6. :rules="rules"
  7. label-width="130px"
  8. :disabled="mode == 'detail'"
  9. v-loading="pageLoading"
  10. >
  11. <el-form-item label="优惠券名称:" prop="couponName">
  12. <el-input
  13. v-model="setQuery.couponName"
  14. size="small"
  15. class="item-width-300"
  16. :maxlength="20"
  17. ></el-input>
  18. </el-form-item>
  19. <el-form-item label="优惠券内容:" required>
  20. <div class="flex">
  21. <div class="flex">
  22. <el-radio v-model="radio1" label="1">满</el-radio>
  23. <el-form-item prop="couponCondition">
  24. <el-input
  25. v-model="setQuery.couponCondition"
  26. size="small"
  27. class="item-width-200"
  28. >
  29. <template slot="append">元</template>
  30. </el-input>
  31. </el-form-item>
  32. </div>
  33. <div class="label">,减</div>
  34. <div class="flex">
  35. <el-form-item prop="couponDiscount">
  36. <el-input
  37. v-model="setQuery.couponDiscount"
  38. size="small"
  39. class="item-width-200"
  40. >
  41. <template slot="append">元</template>
  42. </el-input>
  43. </el-form-item>
  44. </div>
  45. </div>
  46. <div class="flex" :span="24">
  47. <el-radio v-model="radio1" label="2">无门槛,立减</el-radio>
  48. <el-form-item prop="couponDiscount">
  49. <el-input
  50. v-model="setQuery.couponDiscount"
  51. size="small"
  52. class="item-width-200"
  53. >
  54. <template slot="append">元</template>
  55. </el-input>
  56. </el-form-item>
  57. </div>
  58. </el-form-item>
  59. <el-form-item label="使用日期:" prop="contactName">
  60. <div class="flex">
  61. <el-radio v-model="radio2" label="1">{{ "" }}</el-radio>
  62. <el-form-item prop="useStartTime">
  63. <el-date-picker
  64. v-model="date"
  65. size="small"
  66. type="datetimerange"
  67. range-separator="至"
  68. value-format="yyyy-MM-dd HH:mm:ss"
  69. :default-time="['00:00:00', '23:59:59']"
  70. start-placeholder="开始日期"
  71. end-placeholder="结束日期"
  72. :picker-options="pickerOptions"
  73. >
  74. </el-date-picker>
  75. </el-form-item>
  76. </div>
  77. <div class="flex">
  78. <el-radio v-model="radio2" label="2">领券后</el-radio>
  79. <el-select
  80. v-model="setQuery.claimCalmDay"
  81. size="small"
  82. class="item-width-200"
  83. placeholder="请选择"
  84. >
  85. <el-option label="立即生效" :value="0"> </el-option>
  86. <el-option
  87. :disabled="disabled"
  88. :label="setQuery.claimCalmDay + '天生效'"
  89. :value="setQuery.claimCalmDay"
  90. >
  91. <el-input
  92. v-model.number="setQuery.claimCalmDay"
  93. type="number"
  94. size="small"
  95. class="item-width-150"
  96. @blur.stop="disabled = false"
  97. @focus.stop="disabled = true"
  98. >
  99. <template slot="append">天</template>
  100. </el-input>
  101. 生效
  102. </el-option>
  103. </el-select>
  104. <div class="label">有效期</div>
  105. <el-form-item prop="claimValidDay">
  106. <el-input
  107. v-model.number="setQuery.claimValidDay"
  108. size="small"
  109. type="number"
  110. class="item-width-150"
  111. >
  112. <template slot="append">天</template>
  113. </el-input>
  114. </el-form-item>
  115. </div>
  116. <div class="notice">
  117. 例:用户在 1月1日9:00 领券,则该券的可用时间为 6月23日00:00:00 至
  118. 6月23日23:59:59(按自然天计算)
  119. </div>
  120. </el-form-item>
  121. <el-form-item label="发放数量:" prop="limitNum">
  122. <el-input
  123. v-model.number="setQuery.limitNum"
  124. type="number"
  125. size="small"
  126. class="item-width-300"
  127. >
  128. <template slot="append">张</template>
  129. </el-input>
  130. </el-form-item>
  131. <el-form-item label="使用说明:" prop="usrDetail">
  132. <el-input
  133. v-model="setQuery.usrDetail"
  134. class="item-width-300"
  135. type="textarea"
  136. :maxlength="100"
  137. show-word-limit
  138. ></el-input>
  139. </el-form-item>
  140. <el-form-item label="适用商品:" prop="usrDetail">
  141. <el-radio v-model="radio5" label="1">全部商品</el-radio>
  142. <el-radio v-model="radio5" label="2">指定商品</el-radio>
  143. <div class="box" style="width: 600px" v-if="radio5 == 2">
  144. <div class="tab-box">
  145. <el-button size="small" @click="handleChoose">选择商品</el-button>
  146. <el-button size="small" @click="tableData1 = []">全部删除</el-button>
  147. </div>
  148. <el-table
  149. :data="list"
  150. tooltip-effect="dark"
  151. border
  152. v-loading="loading1"
  153. style="width: 100%"
  154. >
  155. <el-table-column
  156. align="center"
  157. label="商品图"
  158. prop="couponName"
  159. show-overflow-tooltip
  160. >
  161. <template slot-scope="scope">
  162. <img class="icon" :src="scope.row.goodsImg" alt="" />
  163. </template>
  164. </el-table-column>
  165. <el-table-column
  166. prop="goodsName"
  167. align="center"
  168. label="商品名称"
  169. show-overflow-tooltip
  170. >
  171. </el-table-column>
  172. <el-table-column
  173. prop="address"
  174. width="180px"
  175. fixed="right"
  176. align="center"
  177. label="操作"
  178. >
  179. <template slot-scope="scope">
  180. <el-button type="text" size="small" @click="handleDel(scope.row.goodsId)">删除</el-button>
  181. </template>
  182. </el-table-column>
  183. </el-table>
  184. <div class="page-box">
  185. <el-pagination
  186. @current-change="handleCurrentChange1"
  187. background
  188. :current-page="chooseQuery.currentPage"
  189. :page-sizes="[10]"
  190. :page-size="chooseQuery.pageSize"
  191. layout="total, sizes, prev, pager, next, jumper"
  192. :total="tableData1.length"
  193. >
  194. </el-pagination>
  195. </div>
  196. </div>
  197. </el-form-item>
  198. <el-form-item label="领取限制:" required>
  199. <el-radio v-model="radio3" label="1">不限制</el-radio>
  200. <el-radio v-model="radio3" label="2">限制</el-radio>
  201. <el-form-item v-if="radio3 == 2" prop="claimNum">
  202. <el-input
  203. v-model.number="setQuery.claimNum"
  204. type="number"
  205. size="small"
  206. class="item-width-300"
  207. >
  208. <template slot="append">次</template>
  209. </el-input>
  210. </el-form-item>
  211. </el-form-item>
  212. <el-form-item label="领取用户限制:" required>
  213. <el-radio v-model="radio4" label="1">不限制</el-radio>
  214. <el-radio v-model="radio4" label="2">限制分类用户领取</el-radio>
  215. <el-form-item v-if="radio4 == 2" prop="claimUser">
  216. <el-checkbox-group v-model="setQuery.claimUser">
  217. <el-checkbox label="99">非会员</el-checkbox>
  218. <el-checkbox
  219. :label="item.value"
  220. v-for="item in comboList"
  221. :key="item.value"
  222. >{{ item.label }}</el-checkbox
  223. >
  224. </el-checkbox-group>
  225. </el-form-item>
  226. </el-form-item>
  227. <el-form-item label="展示位置:" prop="showType">
  228. <el-checkbox-group v-model="setQuery.showType">
  229. <el-checkbox label="1">领取中心</el-checkbox>
  230. <el-checkbox label="2">店铺首页</el-checkbox>
  231. </el-checkbox-group>
  232. </el-form-item>
  233. </el-form>
  234. <div class="btn-group">
  235. <el-button>取 消</el-button>
  236. <el-button type="primary" :loading="loading" @click="save"
  237. >确 定</el-button
  238. >
  239. </div>
  240. <el-dialog title="指定商品" top="30px" width="900px" :visible.sync="dialogTableVisible">
  241. <div class="search">
  242. <div>
  243. <el-input
  244. v-model="query.goodsName"
  245. size="small"
  246. placeholder="请输入商品名称"
  247. class="item-width-200"
  248. ></el-input>
  249. <el-select
  250. v-model="query.goodsType"
  251. size="small"
  252. clearable
  253. class="item-width-200 ml10"
  254. placeholder="请选择类型"
  255. >
  256. <el-option
  257. v-for="item in typeOptions"
  258. :key="item.value"
  259. :label="item.label"
  260. :value="item.value"
  261. >
  262. </el-option>
  263. </el-select>
  264. <el-select
  265. v-model="query.shopId"
  266. size="small"
  267. class="item-width-200 ml10"
  268. placeholder="请搜索并选择店铺"
  269. :remote-method="getShopList"
  270. :loading="shopLoading"
  271. clearable
  272. filterable
  273. remote
  274. >
  275. <el-option
  276. v-for="item in shopOptions"
  277. :key="item.value"
  278. :label="item.label"
  279. :value="item.value"
  280. >
  281. </el-option>
  282. </el-select>
  283. <el-button
  284. class="ml10"
  285. type="primary"
  286. size="small"
  287. icon="el-icon-search"
  288. @click="handleSearch"
  289. >
  290. 搜索
  291. </el-button>
  292. </div>
  293. </div>
  294. <el-table
  295. :data="tableData"
  296. tooltip-effect="dark"
  297. border
  298. v-loading="loading1"
  299. style="width: 100%"
  300. ref="multipleTable"
  301. @selection-change="handleSelectionChange"
  302. >
  303. <el-table-column
  304. type="selection"
  305. width="40">
  306. </el-table-column>
  307. <el-table-column
  308. align="center"
  309. label="商品图"
  310. prop="couponName"
  311. show-overflow-tooltip
  312. >
  313. <template slot-scope="scope">
  314. <img class="icon" :src="scope.row.goodsImg" alt="" />
  315. </template>
  316. </el-table-column>
  317. <el-table-column
  318. prop="goodsName"
  319. align="center"
  320. label="商品名称"
  321. show-overflow-tooltip
  322. >
  323. </el-table-column>
  324. <el-table-column
  325. prop="goodsName"
  326. align="center"
  327. label="商品分类"
  328. show-overflow-tooltip
  329. >
  330. <template slot-scope="scope">
  331. {{ goodsTypeObj[scope.row.goodsType] || "-" }}
  332. </template>
  333. </el-table-column>
  334. <el-table-column
  335. prop="shopName"
  336. align="center"
  337. label="店铺"
  338. show-overflow-tooltip
  339. >
  340. </el-table-column>
  341. </el-table>
  342. <div class="page-box">
  343. <el-pagination
  344. @size-change="handleSizeChange"
  345. @current-change="handleCurrentChange"
  346. background
  347. :current-page="query.currentPage"
  348. :page-sizes="[10, 20, 30, 40]"
  349. :page-size="query.pageSize"
  350. layout="total, sizes, prev, pager, next, jumper"
  351. :total="total"
  352. >
  353. </el-pagination>
  354. </div>
  355. <!-- <div class="btn-group">
  356. <el-button @click="dialogTableVisible = false">取 消</el-button>
  357. <el-button type="primary" @click="saveChoose"
  358. >确 定</el-button
  359. >
  360. </div> -->
  361. </el-dialog>
  362. </div>
  363. </template>
  364. <script>
  365. import { getSetMealNameAndId } from "@/api/common";
  366. import { saveOrUpdate, detail,getGoodsInfoByCoupon } from "@/api/coupon";
  367. import { goodsList } from "@/api/goods";
  368. import { getList } from "@/api/shop";
  369. import { debounce } from "@/utils/index";
  370. export default {
  371. data() {
  372. var validateLimit = (rule, value, callback) => {
  373. if (value === "") {
  374. callback(new Error("请输入发放数量"));
  375. } else if (value > 100000000 || value < 1) {
  376. callback(new Error("应在1~100000000之间"));
  377. } else {
  378. callback();
  379. }
  380. };
  381. return {
  382. mode: "add",
  383. radio: 1,
  384. radio1: "1",
  385. radio2: "1",
  386. radio3: "1",
  387. radio4: "1",
  388. radio5: "1",
  389. setQuery: {
  390. claimCalmDay: 1,
  391. claimNum: 0,
  392. claimUser: [],
  393. claimValidDay: 0,
  394. couponCondition: 0,
  395. couponDiscount: 0,
  396. couponName: "",
  397. couponType: 1,
  398. id: 0,
  399. limitNum: 0,
  400. maxDiscount: 0,
  401. shopId: "",
  402. showType: [],
  403. useEndTime: "",
  404. useGoodsRang: "",
  405. useStartTime: "",
  406. usrDetail: "",
  407. },
  408. date: [],
  409. disabled: false,
  410. pickerOptions: {
  411. disabledDate(time) {
  412. return time.getTime() < Date.now() - 1000 * 60 * 60 * 24;
  413. },
  414. },
  415. rules: {
  416. couponName: [
  417. { required: true, message: "请输入优惠券名称", trigger: "blur" },
  418. ],
  419. couponDiscount: [{ validator: this.validateMoney, trigger: "blur" }],
  420. limitNum: [{ required:true,validator: validateLimit, trigger: "blur" }],
  421. claimNum:[
  422. { required: true, message: '请输入领取次数', trigger: 'blur' },
  423. { type:'number',min: 1, max: 100, message: '领取限制:1~100次', trigger: 'blur' }
  424. ]
  425. },
  426. comboList: [],
  427. loading: false,
  428. tableData: [],
  429. tableData1: [],
  430. chooseList: [],
  431. chooseQuery:{
  432. currentPage:1,
  433. pageSize: 10,
  434. },
  435. loading1: false,
  436. pageLoading: false,
  437. shopLoading: false,
  438. dialogTableVisible: false,
  439. goodsTypeObj: JSON.parse(sessionStorage.getItem("goodsTypeObj")),
  440. typeOptions:[],
  441. shopOptions:[],
  442. query: {
  443. applyState: "",
  444. status: "3",
  445. shopId: "",
  446. goodsName: "",
  447. currentPage: 1,
  448. pageSize: 10,
  449. },
  450. total: 0,
  451. };
  452. },
  453. watch: {
  454. date(val) {
  455. if (val == null) {
  456. this.setQuery.useStartTime = "";
  457. this.setQuery.useEndTime = "";
  458. } else {
  459. this.setQuery.useStartTime = val[0];
  460. this.setQuery.useEndTime = val[1];
  461. }
  462. },
  463. radio1: {
  464. handler: function (val) {
  465. if (val == 1) {
  466. this.$set(this.rules, "couponCondition", [
  467. { validator: this.validateMoney, trigger: "blur" },
  468. ]);
  469. } else {
  470. delete this.rules.couponCondition;
  471. this.$refs.setQuery.clearValidate("couponCondition");
  472. }
  473. },
  474. deep: true,
  475. immediate: true,
  476. },
  477. radio2: {
  478. handler: function (val) {
  479. if (val == 1) {
  480. this.$set(this.rules, "useStartTime", [
  481. { required: true, message: "请选择使用时间", trigger: "change" },
  482. ]);
  483. delete this.rules.claimCalmDay;
  484. delete this.rules.claimValidDay;
  485. } else {
  486. delete this.rules.useStartTime;
  487. this.$refs.setQuery.clearValidate("useStartTime");
  488. this.$set(this.rules, "claimCalmDay", [
  489. { required: true, message: "请输入生效时间", trigger: "blur" },
  490. { validator: this.validateNum, trigger: "blur" },
  491. ]);
  492. this.$set(this.rules, "claimValidDay", [
  493. { required: true, message: "请输入有效天数", trigger: "blur" },
  494. { validator: this.validateNum, trigger: "blur" },
  495. ]);
  496. }
  497. },
  498. deep: true,
  499. immediate: true,
  500. },
  501. // radio3:{
  502. // handler: function (val) {
  503. // if(val == 1){
  504. // delete this.rules.claimNum
  505. // }else{
  506. // this.rules.claimNum = [
  507. // { validator: validateNum, trigger: 'blur' }
  508. // ]
  509. // }
  510. // },
  511. // deep: true,
  512. // immediate: true
  513. // },
  514. radio4: {
  515. handler: function (val) {
  516. if (val == 1) {
  517. delete this.rules.claimUser;
  518. } else {
  519. this.rules.claimUser = [
  520. {
  521. required: true,
  522. message: "请选择领取用户限制",
  523. trigger: "change",
  524. },
  525. ];
  526. }
  527. },
  528. deep: true,
  529. immediate: true,
  530. },
  531. radio5(val){
  532. if(val == 1){
  533. this.setQuery.useGoodsRang = ''
  534. }
  535. }
  536. },
  537. computed: {
  538. list() {
  539. return this.tableData1.slice((this.chooseQuery.currentPage-1)*this.chooseQuery.pageSize,this.chooseQuery.currentPage*this.chooseQuery.pageSize)
  540. }
  541. },
  542. methods: {
  543. handleDel(id){
  544. this.tableData1.map((item,index)=>{
  545. if(item.goodsId == id){
  546. return this.tableData1.splice(index,1)
  547. }
  548. })
  549. },
  550. // 勾选变化
  551. handleSelectionChange(val){
  552. this.chooseList = val
  553. this.tableData1 = this.tableData1.concat(JSON.parse(JSON.stringify(this.chooseList)) )
  554. this.tableData1 = Array.from(new Set(this.tableData1.map(JSON.stringify))).map(JSON.parse)
  555. console.log(this.tableData1.map(item=>item.goodsId));
  556. this.chooseList = []
  557. },
  558. saveChoose(){
  559. this.dialogTableVisible = false
  560. },
  561. handleChoose(){
  562. this.dialogTableVisible = true
  563. this.handleSearch()
  564. },
  565. handleSearch(){
  566. this.query.currentPage = 1;
  567. this.getGoodsList();
  568. },
  569. handleSizeChange(val) {
  570. this.query.currentPage = 1;
  571. this.query.pageSize = val;
  572. this.getGoodsList();
  573. },
  574. handleCurrentChange(val) {
  575. this.query.currentPage = val;
  576. this.getGoodsList();
  577. },
  578. // 静态表格手动分页
  579. handleCurrentChange1(val) {
  580. this.chooseQuery.currentPage = val;
  581. },
  582. getGoodsList() {
  583. this.loading1 = true;
  584. goodsList(this.query).then((res) => {
  585. this.loading1 = false;
  586. if (res.state == "Success") {
  587. this.tableData = res.content.records;
  588. this.total = res.content.total;
  589. }
  590. });
  591. },
  592. validateNum(rule, value, callback) {
  593. if (value > 200 || value < 1) {
  594. callback(new Error("应在1~200之间"));
  595. } else {
  596. callback();
  597. }
  598. },
  599. validateMoney(rule, value, callback) {
  600. if (Number(value).toString() == "NaN") {
  601. callback(new Error("请输入数字"));
  602. } else if (value > 100000 || value < 0.01) {
  603. callback(new Error("金额应在0.01~100000.00之间"));
  604. } else {
  605. callback();
  606. }
  607. },
  608. // 获取套餐列表
  609. getSetMealNameAndId() {
  610. getSetMealNameAndId().then((res) => {
  611. if (res.state == "Success") {
  612. for (const key in res.content) {
  613. if (res.content.hasOwnProperty.call(res.content, key)) {
  614. this.comboList.push({
  615. label: res.content[key],
  616. value: key,
  617. });
  618. }
  619. }
  620. }
  621. });
  622. },
  623. // 获取店铺列表
  624. getShopList:debounce(function(val) {
  625. if(val){
  626. getList({shopNameOrPhoneNum: val,
  627. currentPage: 1,
  628. pageSize: 20}).then((res) => {
  629. this.shopLoading = false;
  630. if (res.state == "Success") {
  631. this.shopOptions = []
  632. res.content.records.map(item=>{
  633. this.shopOptions.push({
  634. label:item.shopName,
  635. value:item.shopId
  636. })
  637. })
  638. }
  639. });
  640. }else{
  641. this.shopOptions = []
  642. }
  643. }),
  644. getGoodsInfoByCoupon(id){
  645. getGoodsInfoByCoupon({id,currentPage:1,pageSize:999}).then(res=>{
  646. if (res.state == "Success") {
  647. this.tableData1 = res.content.records
  648. }
  649. })
  650. },
  651. getDetail(id) {
  652. this.pageLoading = true;
  653. detail({ id }).then((res) => {
  654. this.pageLoading = false;
  655. if (res.state == "Success") {
  656. let obj = JSON.parse(JSON.stringify(res.content));
  657. if (obj.showType == 3) {
  658. obj.showType = ["1", "2"];
  659. } else if (obj.showType) {
  660. obj.showType = [obj.showType.toString()];
  661. } else {
  662. obj.showType = [];
  663. }
  664. if (obj.couponCondition) {
  665. this.radio1 = "1";
  666. } else {
  667. this.radio1 = "2";
  668. }
  669. obj.claimCalmDay = obj.claimCalmDay || 1;
  670. obj.claimValidDay = obj.claimValidDay || 0;
  671. if (obj.claimValidDay > 0) {
  672. this.radio2 = "2";
  673. } else if (obj.useStartTime && obj.useEndTime) {
  674. this.radio2 = "1";
  675. this.date = [obj.useStartTime, obj.useEndTime];
  676. }
  677. if (obj.claimNum == 0) {
  678. this.radio3 = "1";
  679. } else {
  680. this.radio3 = "2";
  681. }
  682. if (obj.claimUser == 0) {
  683. this.radio4 = "1";
  684. obj.claimUser = [];
  685. } else {
  686. this.radio4 = "2";
  687. obj.claimUser = obj.claimUser.split(",");
  688. }
  689. if(obj.useGoodsRang){
  690. this.radio5 = '2'
  691. this.getGoodsInfoByCoupon(id)
  692. }else{
  693. this.radio5 = '1'
  694. }
  695. this.setQuery = obj;
  696. }
  697. });
  698. },
  699. save() {
  700. this.$refs.setQuery.validate((v) => {
  701. if (v) {
  702. let query = JSON.parse(JSON.stringify(this.setQuery));
  703. if (this.radio2 == 1) {
  704. delete query.claimCalmDay;
  705. delete query.claimValidDay;
  706. } else {
  707. delete query.useStartTime;
  708. delete query.useEndTime;
  709. }
  710. if (this.radio3 == 1) {
  711. query.claimNum = 0;
  712. }
  713. if (this.radio4 == 1) {
  714. query.claimUser = 0;
  715. } else {
  716. query.claimUser = query.claimUser.join();
  717. }
  718. if (query.showType.length == 2) {
  719. query.showType = 3;
  720. } else if (query.showType.length == 1) {
  721. query.showType = query.showType[0];
  722. } else if (!query.showType.length) {
  723. delete query.showType;
  724. }
  725. if (this.radio5 == 2) {
  726. query.useGoodsRang = this.tableData1.map(item=>item.goodsId).toString()
  727. }else{
  728. query.useGoodsRang = ''
  729. }
  730. if (!query.id) {
  731. delete query.id;
  732. }
  733. this.loading = true;
  734. saveOrUpdate(query).then((res) => {
  735. this.loading = false;
  736. if (res.state == "Success") {
  737. this.$notify({
  738. title: "成功",
  739. message: "操作成功",
  740. type: "success",
  741. });
  742. this.$router.push("/operationManage/couponManage/index");
  743. }
  744. });
  745. }
  746. });
  747. },
  748. },
  749. created() {
  750. this.mode = this.$route.query.mode || "add";
  751. if (this.$route.query.id) {
  752. this.getDetail(this.$route.query.id);
  753. }
  754. this.getSetMealNameAndId();
  755. for (const key in this.goodsTypeObj) {
  756. if (Object.hasOwnProperty.call(this.goodsTypeObj, key)) {
  757. this.typeOptions.push({
  758. label:this.goodsTypeObj[key],
  759. value:key
  760. })
  761. }
  762. }
  763. },
  764. };
  765. </script>
  766. <style lang="scss" scoped>
  767. .fullDiscountCoupon {
  768. .icon{
  769. width: 50px;
  770. height: 50px;
  771. }
  772. .label {
  773. font-size: 14px;
  774. color: #606266;
  775. height: 32px;
  776. align-self: flex-start;
  777. padding: 0 10px;
  778. }
  779. .flex {
  780. display: flex;
  781. align-items: center;
  782. margin-bottom: 10px;
  783. }
  784. .notice {
  785. font-size: 12px;
  786. color: #aaa;
  787. margin-top: 10px;
  788. }
  789. .btn-group {
  790. display: flex;
  791. align-items: center;
  792. justify-content: center;
  793. }
  794. }
  795. </style>