com-card-secret.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template id="com-card-secret">
  2. <div class="com-card-secret">
  3. <el-card class="edit-card-secretd" shadow="never">
  4. <div slot="header" class="clearfix">
  5. <div class="card-title card-secretd-title">虚拟卡密<span class="card-secretd-sub-title"></span></div>
  6. </div>
  7. <el-form :model="form" size="small">
  8. <!-- 虚拟卡密开始 -->
  9. <el-form-item label="赠送卡密" label-width="80px">
  10. <el-select size="small" style="min-width: 350px" v-model="form.cate_id"
  11. placeholder="状态">
  12. <el-option v-if="data.no_use_num > 0" v-for="(data,index) in cate_list" :label="data.name+'(已经使用'+data.use_num+',未使用'+data.no_use_num+')'" :value="data.id" :key="data.id"></el-option>
  13. </el-select>
  14. </el-form-item>
  15. <!-- 虚拟卡密结束 -->
  16. </el-form>
  17. </el-card>
  18. </div>
  19. </template>
  20. <script>
  21. Vue.component('com-card-secret', {
  22. template: "#com-card-secret",
  23. props: {
  24. goods_id: {
  25. type: Number | String,
  26. default: 0
  27. }
  28. },
  29. data() {
  30. return {
  31. form: {
  32. cate_id: '',
  33. },
  34. cate_list:[],
  35. }
  36. },
  37. watch: {
  38. form:{
  39. deep:true,
  40. immediate: true,
  41. handler(value){
  42. this.$emit("select", {CardSecret: this.form});
  43. }
  44. }
  45. },
  46. mounted: function() {
  47. this.cardsecret();
  48. },
  49. methods: {
  50. //优惠券列表
  51. cardsecret() { console.log(11111);
  52. request({
  53. params: {
  54. r: 'card-secret/goods/edit',
  55. goods_id: this.goods_id,
  56. },
  57. method: 'get',
  58. }).then(e => { console.log(3333);
  59. if (e.data.code == 0 && !isEmpty(e.data.data)) {
  60. this.cate_list = e.data.data.cate_list;
  61. if(this.cate_list){
  62. var status = 0;
  63. $.each(this.cate_list,function($k,$v){
  64. if(this.cate_id == $v.cate_id && $v.no_use_num >0){
  65. status = 1;
  66. }
  67. });
  68. if(status){
  69. this.form.cate_id = e.data.data.cate_id;
  70. }else{
  71. this.form.cate_id = '';
  72. }
  73. }
  74. }
  75. })
  76. },
  77. }
  78. });
  79. </script>
  80. <style>
  81. .com-card-secret{
  82. margin-bottom:20px;
  83. }
  84. </style>