edit.vue 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. <template>
  2. <div class="subPage">
  3. <form class="mainForm">
  4. <!-- <h1 style="font-size:22px;">{{isEdit === 0 ? '新建' : '编辑'}}{{couponInfo.CouponType === 'goods' ? '饮品优惠券' : '课程优惠券'}}</h1> -->
  5. <ul>
  6. <li class="flex-h">
  7. <span>选择案场:<em>*</em></span>
  8. <div class="flex-item">
  9. <div style="width:50%">
  10. <el-select v-model="couponInfo.CaseId" placeholder="请选择" @change="caseChange" :disabled="isEdit">
  11. <el-option
  12. v-for="item in cases"
  13. :key="item.CaseId"
  14. :label="item.CaseName"
  15. :value="item.CaseId">
  16. </el-option>
  17. </el-select>
  18. </div>
  19. </div>
  20. </li>
  21. <li class="flex-h">
  22. <span>券图片:<em>*</em></span>
  23. <div class="flex-item">
  24. <div>
  25. <el-upload
  26. :disabled="isEdit"
  27. class="avatar-uploader"
  28. action='string'
  29. :http-request="toolClass.upload"
  30. :show-file-list="false"
  31. :on-success="handleAvatarSuccess">
  32. <img v-if="couponInfo.Images[0].CouponImageUrl" :src="couponInfo.Images[0].CouponImageUrl" class="avatar">
  33. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  34. </el-upload>
  35. </div>
  36. </div>
  37. </li>
  38. <li class="flex-h">
  39. <span>券名称:<em>*</em></span>
  40. <div class="flex-item">
  41. <div style="width:200px;">
  42. <el-input
  43. placeholder="请输入"
  44. v-model="couponInfo.CouponName"
  45. clearable>
  46. </el-input>
  47. </div>
  48. </div>
  49. </li>
  50. <li class="flex-h">
  51. <span>券类型:<em>*</em></span>
  52. <div class="flex-item">
  53. <div style="width:50%">
  54. <el-select v-model="couponInfo.CouponType" placeholder="请选择" @change="couponTypeChange" :disabled="isEdit">
  55. <el-option
  56. v-for="item in TypeList"
  57. :key="item.id"
  58. :label="item.value"
  59. :value="item.id">
  60. </el-option>
  61. </el-select>
  62. </div>
  63. </div>
  64. </li>
  65. <li class="flex-h">
  66. <span>券价格:<em>*</em></span>
  67. <div class="flex-item">
  68. <div style="width:200px;">
  69. <el-input
  70. :disabled="isEdit"
  71. placeholder="请输入"
  72. v-model="couponInfo.Price"
  73. clearable>
  74. </el-input>
  75. </div>
  76. </div>
  77. </li>
  78. <li class="flex-h">
  79. <span>总张数:<em>*</em></span>
  80. <div class="flex-item">
  81. <div style="width:200px;">
  82. <el-input
  83. :disabled="isEdit"
  84. placeholder="请输入"
  85. v-model="couponInfo.TotalCount"
  86. clearable>
  87. </el-input>
  88. </div>
  89. </div>
  90. </li>
  91. <li class="flex-h">
  92. <span>发送类型:<em>*</em></span>
  93. <div class="flex-item">
  94. <div>
  95. <el-radio v-model="couponInfo.SendType" label="channel" :disabled="isEdit">渠道</el-radio>
  96. <el-radio v-if="couponInfo.CouponType === 'course'" v-model="couponInfo.SendType" label="case" :disabled="isEdit">案场</el-radio>
  97. <el-radio v-model="couponInfo.SendType" label="system" :disabled="isEdit">系统</el-radio>
  98. </div>
  99. </div>
  100. </li>
  101. <li class="flex-h" v-if="couponInfo.SendType === 'channel'">
  102. <span>选择渠道:<em>*</em></span>
  103. <div class="flex-item">
  104. <div style="width:50%">
  105. <el-select v-model="couponInfo.ChannelId" placeholder="请选择" :disabled="isEdit">
  106. <el-option
  107. v-for="item in channelList"
  108. :key="item.ChannelId"
  109. :label="item.ChannelName"
  110. :value="item.ChannelId">
  111. </el-option>
  112. </el-select>
  113. </div>
  114. </div>
  115. </li>
  116. <li class="flex-h">
  117. <span>目标商品:<em>*</em></span>
  118. <div class="flex-item">
  119. <div>
  120. <el-radio v-model="couponInfo.IsAll" label="1" :disabled="isEdit">全部商品</el-radio>
  121. <el-radio v-model="couponInfo.IsAll" label="0" :disabled="isEdit">指定商品</el-radio>
  122. </div>
  123. </div>
  124. </li>
  125. <li class="flex-h" v-if="couponInfo.IsAll === '0'">
  126. <div class="flex-item">
  127. <div style="border: 1px solid #eee;">
  128. <el-table
  129. :data="couponInfo.Targets"
  130. stripe
  131. style="width: 100%">
  132. <el-table-column
  133. prop="TargetName"
  134. label="商品">
  135. </el-table-column>
  136. <el-table-column
  137. prop="TargetType"
  138. label="分类">
  139. <template slot-scope="scope">
  140. {{returnGoodsType(scope.row.TargetType)}}
  141. </template>
  142. </el-table-column>
  143. <el-table-column label="操作">
  144. <template slot-scope="scope">
  145. <el-button
  146. size="mini"
  147. type="warning"
  148. @click="deleteGoodsItem(scope.$index, scope.row)" :disabled="isEdit">删除</el-button>
  149. </template>
  150. </el-table-column>
  151. </el-table>
  152. <div style="text-align:center;padding:10px 0;">
  153. <el-button type="success" size="mini" @click="addGoods" :disabled="isEdit">添加商品</el-button>
  154. </div>
  155. </div>
  156. </div>
  157. </li>
  158. <li class="flex-h" v-if="couponInfo.CouponType === 'goods'">
  159. <span>券有效时间:<em>*</em></span>
  160. <div class="flex-item">
  161. <div>
  162. <div class="addLine flex-h" style="align-item:center;margin-bottom:20px;">
  163. <el-radio v-model="postData.TimeType" label="1" :disabled="isEdit">固定时间</el-radio>
  164. <el-date-picker
  165. value-format="yyyy-MM-dd 00:00:00"
  166. :disabled="isEdit"
  167. v-model="couponInfo.StartDate"
  168. type="date"
  169. placeholder="选择起始日期">
  170. </el-date-picker>
  171. <span style="line-height:40px;">至</span>
  172. <el-date-picker
  173. value-format="yyyy-MM-dd 23:59:59"
  174. :disabled="isEdit"
  175. v-model="couponInfo.EndDate"
  176. type="date"
  177. placeholder="选择截止日期">
  178. </el-date-picker>
  179. </div>
  180. <div class="addLine flex-h" style="align-item:center;">
  181. <el-radio v-model="postData.TimeType" label="2" :disabled="isEdit">领取后</el-radio>
  182. <span style="width:100px;">
  183. <el-input
  184. :disabled="isEdit"
  185. placeholder="请输入"
  186. v-model="couponInfo.ValidDays"
  187. clearable>
  188. </el-input>
  189. </span>
  190. <span style="line-height:40px;">天</span>
  191. </div>
  192. </div>
  193. </div>
  194. </li>
  195. <li class="flex-h" v-if="couponInfo.CouponType === 'course'">
  196. <span>券有效时间:<em>*</em></span>
  197. <div class="flex-item">
  198. <div>
  199. <el-date-picker
  200. value-format="yyyy-MM-dd 00:00:00"
  201. :disabled="isEdit"
  202. v-model="couponInfo.StartDate"
  203. type="date"
  204. placeholder="选择起始日期">
  205. </el-date-picker>
  206. <span style="line-height:40px;">至</span>
  207. <el-date-picker
  208. value-format="yyyy-MM-dd 23:59:59"
  209. :disabled="isEdit"
  210. v-model="couponInfo.EndDate"
  211. type="date"
  212. placeholder="选择截止日期">
  213. </el-date-picker>
  214. </div>
  215. </div>
  216. </li>
  217. <li class="flex-h" v-if="couponInfo.SendType !== 'case' && couponInfo.SendType !== 'system'">
  218. <span>视频:<em>*</em></span>
  219. <div class="flex-item">
  220. <div style="vertical-align: middle;">
  221. <a style="line-height: 40px;" v-if="videoOff" :href="couponInfo.VideoUrl" target="blank">{{couponInfo.VideoUrl}}</a>
  222. <el-upload
  223. :disabled="isEdit"
  224. class="avatar-uploader"
  225. action='string'
  226. :http-request="toolClass.upload"
  227. :show-file-list="false"
  228. :on-success="videoSuccess">
  229. <a style="line-height: 40px;padding: 0 10px;" :disabled="isEdit">{{videoOff ? '更换' : '添加'}}视频</a>
  230. </el-upload>
  231. <el-button v-if="videoOff" type="danger" @click="deleteVideo" :disabled="isEdit">删除视频</el-button>
  232. </div>
  233. </div>
  234. </li>
  235. <li class="flex-h">
  236. <span>分享描述:<em>*</em></span>
  237. <div class="flex-item">
  238. <div>
  239. <el-input
  240. type="textarea"
  241. :rows="2"
  242. placeholder="请输入"
  243. v-model="couponInfo.Share.CouponShareInfo">
  244. </el-input>
  245. </div>
  246. </div>
  247. </li>
  248. <li class="flex-h">
  249. <span>规则描述:<em>*</em></span>
  250. <div class="flex-item">
  251. <div>
  252. <el-input
  253. type="textarea"
  254. :rows="2"
  255. placeholder="请输入"
  256. v-model="couponInfo.Share.UseRule">
  257. </el-input>
  258. </div>
  259. </div>
  260. </li>
  261. <li class="flex-h">
  262. <span>使用说明:<em>*</em></span>
  263. <div class="flex-item">
  264. <div>
  265. <el-input
  266. type="textarea"
  267. :rows="2"
  268. placeholder="请输入"
  269. v-model="couponInfo.Share.UseInstruction">
  270. </el-input>
  271. </div>
  272. </div>
  273. </li>
  274. <li style="text-align:center">
  275. <el-button type="primary" size="mini" @click="submit">保存</el-button>
  276. <el-button type="danger" size="mini" @click="cancel">取消</el-button>
  277. </li>
  278. </ul>
  279. </form>
  280. <el-dialog
  281. title="选择指定商品"
  282. :visible.sync="centerDialogVisible"
  283. width="650px"
  284. center>
  285. <div>
  286. <div v-if="couponInfo.CouponType === 'goods'">
  287. <el-table
  288. ref="multipleTable"
  289. :data="goodsList.list"
  290. tooltip-effect="dark"
  291. style="width: 100%"
  292. @selection-change="handleGoodsChange">
  293. <el-table-column
  294. type="selection">
  295. </el-table-column>
  296. <el-table-column
  297. prop="GoodsName"
  298. label="商品名称">
  299. </el-table-column>
  300. <el-table-column
  301. prop="TypeId"
  302. label="类别">
  303. <template slot-scope="scope">
  304. <span>{{returnGoodsType(scope.row.TypeId)}}</span>
  305. </template>
  306. </el-table-column>
  307. <el-table-column
  308. prop="Price"
  309. label="价格">
  310. </el-table-column>
  311. </el-table>
  312. <el-pagination
  313. @current-change="handleCurrentChange"
  314. :current-page.sync="postData.page"
  315. :page-size="postData.pagesize"
  316. layout="prev, pager, next, jumper"
  317. :total="total">
  318. </el-pagination>
  319. </div>
  320. <div v-if="couponInfo.CouponType === 'course'">
  321. <el-table
  322. ref="multipleTable"
  323. :data="courseList"
  324. tooltip-effect="dark"
  325. style="width: 100%"
  326. @selection-change="handleCourseChange">
  327. <el-table-column
  328. type="selection">
  329. </el-table-column>
  330. <el-table-column
  331. prop="CourseName"
  332. label="课程名称">
  333. </el-table-column>
  334. <el-table-column
  335. prop="BeginDate"
  336. label="开始时间">
  337. <template slot-scope="scope">
  338. <span>{{toolClass.dateFormat(scope.row.BeginDate, 'yyyy-MM-dd')}}</span>
  339. </template>
  340. </el-table-column>
  341. <el-table-column
  342. prop="EndDate"
  343. label="结束时间">
  344. <template slot-scope="scope">
  345. <span>{{toolClass.dateFormat(scope.row.EndDate, 'yyyy-MM-dd')}}</span>
  346. </template>
  347. </el-table-column>
  348. <el-table-column
  349. prop="LocationId"
  350. label="类别">
  351. </el-table-column>
  352. <el-table-column
  353. prop="Price"
  354. label="价格">
  355. </el-table-column>
  356. </el-table>
  357. <el-pagination
  358. @current-change="handleCurrentChange"
  359. :current-page.sync="postData.page"
  360. :page-size="postData.pagesize"
  361. layout="prev, pager, next, jumper"
  362. :total="total">
  363. </el-pagination>
  364. </div>
  365. </div>
  366. <span slot="footer" class="dialog-footer">
  367. <el-button @click="centerDialogVisible = false">取 消</el-button>
  368. <el-button type="primary" @click="sureAddItem">确 定</el-button>
  369. </span>
  370. </el-dialog>
  371. </div>
  372. </template>
  373. <script>
  374. import { mapState, createNamespacedHelpers } from 'vuex'
  375. const { mapActions: mapCouponActions } = createNamespacedHelpers('coupon')
  376. const { mapState: mapChannelState, mapActions: mapChannelActions } = createNamespacedHelpers('channel')
  377. const { mapState: mapGoodsState, mapActions: mapGoodsActions } = createNamespacedHelpers('goods')
  378. const { mapState: mapCourseState, mapActions: mapCourseActions } = createNamespacedHelpers('course')
  379. export default {
  380. name: '',
  381. data () {
  382. return {
  383. videoOff: false,
  384. total: 0,
  385. centerDialogVisible: false,
  386. type: this.$route.query.type || '', // goods、course
  387. isEdit: !!this.$route.query.id,
  388. ChannelList: [], // 渠道列表
  389. TypeList: [{ // 类型列表
  390. value: '商品券',
  391. id: 'goods'
  392. }, {
  393. value: '课程券',
  394. id: 'course'
  395. }],
  396. currentList: [{
  397. Name: 'ccc',
  398. Type: 'xxx'
  399. }], // 指定商品数据
  400. couponInfo: {
  401. CaseId: '',
  402. CouponName: '',
  403. CouponType: '',
  404. Price: '',
  405. TotalCount: '',
  406. SendType: '',
  407. IsAll: '',
  408. StartDate: '',
  409. EndDate: '',
  410. ValidDays: '',
  411. VideoUrl: '',
  412. ChannelId: '',
  413. Images: [{
  414. CouponImageUrl: ''
  415. }],
  416. Share: {
  417. CouponShareInfo: '',
  418. UseRule: '',
  419. UseInstruction: ''
  420. },
  421. Targets: []
  422. },
  423. postData: {
  424. page: 1,
  425. pagesize: 6,
  426. },
  427. currentSelectArr: [],
  428. }
  429. },
  430. mounted () {
  431. this.$nextTick(function () {
  432. this.GetChannelListList({
  433. caseid: this.defaultCaseId,
  434. page: 1,
  435. pagesize: 10000
  436. }).then(() => {
  437. this.GetGoodTypes({ pagesize: 1000, caseid: this.$route.query.caseid }).then(() => {
  438. if (this.$route.query.id) {
  439. this.getCouponById({
  440. id: this.$route.query.id
  441. }).then((res) => {
  442. // console.log(JSON.stringify(res))
  443. if (res.coupon.CaseId !== '') {
  444. var aRes = res
  445. this.GetChannelListList({
  446. caseid: res.coupon.CaseId,
  447. page: 1,
  448. pagesize: 10000
  449. }).then((res) => {
  450. aRes.coupon.IsAll = String(aRes.coupon.IsAll)
  451. if (aRes.coupon.VideoUrl !== '') {
  452. this.videoOff = true
  453. }
  454. this.couponInfo = aRes.coupon
  455. })
  456. } else {
  457. res.coupon.IsAll = String(res.coupon.IsAll)
  458. if (res.coupon.VideoUrl !== '') {
  459. this.videoOff = true
  460. }
  461. this.couponInfo = res.coupon
  462. }
  463. })
  464. }
  465. })
  466. })
  467. })
  468. },
  469. computed: {
  470. ...mapState({
  471. cases: x => x.app.cases.list,
  472. defaultCaseId: x => x.app.cases.default
  473. }),
  474. ...mapChannelState({
  475. channelList: x => x.channelList,
  476. }),
  477. ...mapGoodsState({
  478. goodsList: x => x.goodsList,
  479. goodsTypes: x => x.goodsTypes.list,
  480. }),
  481. ...mapCourseState({
  482. courseList: x => x.courseLister,
  483. }),
  484. CaseId: {
  485. get () {
  486. return this.couponInfo.caseid || this.defaultCaseId
  487. },
  488. set (val) {
  489. this.couponInfo.caseid = val
  490. }
  491. },
  492. },
  493. methods: {
  494. ...mapGoodsActions([
  495. 'GetGoodsList',
  496. 'GetGoodTypes',
  497. ]),
  498. ...mapCouponActions([
  499. 'addCoupon',
  500. 'getCouponById',
  501. 'editCoupon',
  502. ]),
  503. ...mapChannelActions([
  504. 'GetChannelListList',
  505. ]),
  506. ...mapCourseActions([
  507. 'getCourseLister',
  508. ]),
  509. returnGoodsType (val) {
  510. for (var n = 0; n < this.goodsTypes.length; n++) {
  511. if (this.goodsTypes[n].TypeId === val) {
  512. return this.goodsTypes[n].TypeName
  513. }
  514. }
  515. },
  516. deleteVideo () { // 删除视频
  517. this.couponInfo.VideoUrl = ''
  518. this.videoOff = false
  519. },
  520. caseChange () { // 选择案场
  521. this.couponInfo.ChannelId = ''
  522. this.GetChannelListList({
  523. caseid: this.couponInfo.CaseId,
  524. page: 1,
  525. pagesize: 10000
  526. })
  527. },
  528. sureAddItem () { // 确定添加指定商品
  529. var bool = true
  530. this.couponInfo.Targets = this.couponInfo.Targets || []
  531. if (this.couponInfo.CouponType === 'goods') {
  532. for (var n = 0; n < this.currentSelectArr.length; n++) {
  533. if (this.couponInfo.Targets.length) {
  534. bool = true
  535. for (var a = 0; a < this.couponInfo.Targets.length; a++) {
  536. if (this.currentSelectArr[n].GoodsId === this.couponInfo.Targets[a].TargetId) {
  537. bool = false
  538. }
  539. }
  540. if (bool) {
  541. this.couponInfo.Targets.push({
  542. TargetName: this.currentSelectArr[n].GoodsName,
  543. TargetId: this.currentSelectArr[n].GoodsId,
  544. TargetType: this.currentSelectArr[n].TypeId
  545. })
  546. }
  547. } else {
  548. this.couponInfo.Targets.push({
  549. TargetName: this.currentSelectArr[n].GoodsName,
  550. TargetId: this.currentSelectArr[n].GoodsId,
  551. TargetType: this.currentSelectArr[n].TypeId
  552. })
  553. }
  554. }
  555. } else if (this.couponInfo.CouponType === 'course') {
  556. for (var x = 0; x < this.currentSelectArr.length; x++) {
  557. if (this.couponInfo.Targets.length) {
  558. bool = true
  559. for (var y = 0; y < this.couponInfo.Targets.length; y++) {
  560. if (this.currentSelectArr[x].CourseId === this.couponInfo.Targets[y].TargetId) {
  561. bool = false
  562. }
  563. }
  564. if (bool) {
  565. this.couponInfo.Targets.push({
  566. TargetName: this.currentSelectArr[x].CourseName,
  567. TargetId: this.currentSelectArr[x].CourseId,
  568. TargetType: this.currentSelectArr[x].CourseType
  569. })
  570. }
  571. } else {
  572. this.couponInfo.Targets.push({
  573. TargetName: this.currentSelectArr[x].CourseName,
  574. TargetId: this.currentSelectArr[x].CourseId,
  575. TargetType: this.currentSelectArr[x].CourseType
  576. })
  577. }
  578. }
  579. }
  580. this.centerDialogVisible = false
  581. },
  582. handleGoodsChange (val) {
  583. this.currentSelectArr = val
  584. },
  585. handleCourseChange (val) {
  586. this.currentSelectArr = val
  587. },
  588. couponTypeChange () {
  589. if (this.goodsList.length) {
  590. this.goodsList = []
  591. }
  592. if (this.courseList.length) {
  593. this.courseList = []
  594. }
  595. this.couponInfo.Targets = []
  596. },
  597. addGoods () { // 添加指定商品
  598. if (this.couponInfo.CouponType === 'goods') {
  599. this.GetGoodsList({
  600. ...this.postData,
  601. caseid: this.couponInfo.CaseId
  602. }).then((res) => {
  603. this.total = res.pagenum
  604. this.centerDialogVisible = true
  605. })
  606. } else if (this.couponInfo.CouponType === 'course') {
  607. this.getCourseLister({
  608. ...this.postData,
  609. caseid: this.couponInfo.CaseId
  610. }).then((res) => {
  611. this.total = res.pagenum
  612. this.centerDialogVisible = true
  613. console.log(JSON.stringify(this.courseList))
  614. })
  615. }
  616. },
  617. checkInfo () { // 校验表单信息
  618. if (this.couponInfo.CaseId === '') {
  619. this.$message({
  620. type: 'error',
  621. message: '案场不能为空'
  622. })
  623. return false
  624. }
  625. if (this.couponInfo.Images[0].CouponImageUrl === '') {
  626. this.$message({
  627. type: 'error',
  628. message: '券图片不能为空'
  629. })
  630. return false
  631. }
  632. if (this.couponInfo.CouponName === '') {
  633. this.$message({
  634. type: 'error',
  635. message: '券名称不能为空'
  636. })
  637. return false
  638. }
  639. if (this.couponInfo.CouponType === '') {
  640. this.$message({
  641. type: 'error',
  642. message: '券类型不能为空'
  643. })
  644. return false
  645. }
  646. if (this.couponInfo.Price === '') {
  647. this.$message({
  648. type: 'error',
  649. message: '券价格不能为空'
  650. })
  651. return false
  652. }
  653. if (this.couponInfo.TotalCount === '') {
  654. this.$message({
  655. type: 'error',
  656. message: '总张数不能为空'
  657. })
  658. return false
  659. }
  660. if (this.couponInfo.SendType === '') {
  661. this.$message({
  662. type: 'error',
  663. message: '发送类型不能为空'
  664. })
  665. return false
  666. }
  667. if (this.couponInfo.SendType === 'channel' && this.couponInfo.ChannelId === '') {
  668. this.$message({
  669. type: 'error',
  670. message: '渠道不能为空'
  671. })
  672. return false
  673. }
  674. if (this.couponInfo.IsAll === 0 && this.couponInfo.Targets[0].TargetId === '') {
  675. this.$message({
  676. type: 'error',
  677. message: '目标商品不能为空'
  678. })
  679. return false
  680. }
  681. if (this.couponInfo.SendType === 'channel' && this.couponInfo.VideoUrl === '') {
  682. this.$message({
  683. type: 'error',
  684. message: '视频不能为空'
  685. })
  686. return false
  687. }
  688. if (this.couponInfo.Share.CouponShareInfo === '') {
  689. this.$message({
  690. type: 'error',
  691. message: '分享描述不能为空'
  692. })
  693. return false
  694. }
  695. if (this.couponInfo.Share.UseRule === '') {
  696. this.$message({
  697. type: 'error',
  698. message: '使用规则不能为空'
  699. })
  700. return false
  701. }
  702. if (this.couponInfo.Share.UseInstruction === '') {
  703. this.$message({
  704. type: 'error',
  705. message: '使用说明不能为空'
  706. })
  707. return false
  708. }
  709. return true
  710. },
  711. submit () { // 保存
  712. if (this.$route.query.id) {
  713. if (this.couponInfo.ValidDays) {
  714. this.couponInfo.StartDate = undefined
  715. this.couponInfo.EndDate = undefined
  716. }
  717. if (!this.checkInfo()) {
  718. return false
  719. }
  720. this.editCoupon({
  721. ...this.couponInfo,
  722. IsAll: this.couponInfo.IsAll - 0,
  723. TotalCount: this.couponInfo.TotalCount - 0,
  724. ValidDays: this.couponInfo.ValidDays - 0 || 0
  725. }).then((res) => {
  726. this.$alert('操作成功', '提示', {
  727. confirmButtonText: '确定',
  728. callback: action => {
  729. this.$router.push({ name: 'couponList' })
  730. }
  731. })
  732. })
  733. } else {
  734. if (this.couponInfo.ValidDays) {
  735. this.couponInfo.StartDate = undefined
  736. this.couponInfo.EndDate = undefined
  737. }
  738. if (!this.checkInfo()) {
  739. return false
  740. }
  741. this.addCoupon({
  742. ...this.couponInfo,
  743. IsAll: this.couponInfo.IsAll - 0,
  744. TotalCount: this.couponInfo.TotalCount - 0,
  745. ValidDays: this.couponInfo.ValidDays - 0 || 0
  746. }).then((res) => {
  747. this.$message({
  748. type: 'success',
  749. message: '操作成功'
  750. })
  751. this.$router.push({ name: 'couponList' })
  752. })
  753. }
  754. },
  755. cancel () { // 取消
  756. this.$router.push({ name: 'couponList' })
  757. },
  758. deleteGoodsItem (index, row) { // 删除指定商品item
  759. this.couponInfo.Targets.splice(index, 1)
  760. },
  761. handleAvatarSuccess (res, file) {
  762. this.couponInfo.Images[0].CouponImageUrl = res.result.url
  763. },
  764. videoSuccess (res, file) {
  765. this.videoOff = true
  766. this.couponInfo.VideoUrl = res.result.url
  767. },
  768. handleCurrentChange (val) { // 跳转到分页
  769. this.postData.page = val
  770. if (this.couponInfo.CouponType === 'goods') {
  771. this.GetGoodsList({
  772. ...this.postData,
  773. caseid: this.couponInfo.CaseId
  774. }).then((res) => {
  775. this.total = res.pagenum
  776. })
  777. } else if (this.couponInfo.CouponType === 'course') {
  778. this.getCourseLister({
  779. ...this.postData,
  780. caseid: this.couponInfo.CaseId
  781. }).then((res) => {
  782. this.total = res.pagenum
  783. })
  784. }
  785. }
  786. }
  787. }
  788. </script>
  789. <!-- Add "scoped" attribute to limit CSS to this component only -->
  790. <style lang="scss" scoped>
  791. .addLine {
  792. > * {
  793. margin-right: 10px;
  794. }
  795. }
  796. .mainForm > ul > li > div > div > button {
  797. margin-top: 0;
  798. }
  799. </style>