com-smartform-goods.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. use common\helpers\AddonHelper;
  4. ComponentHelper::loadComponentView('coupon-select', AddonHelper::getAddonRootPath('Coupon') . 'backend/views/components');
  5. ComponentHelper::loadComponentView('form-diy-list', AddonHelper::getAddonRootPath('SmartForm') . 'backend/views/components/form');
  6. ?>
  7. <style>
  8. .flexcenter{
  9. display:flex;
  10. justify-content: center;
  11. }
  12. </style>
  13. <template id="com-smartform-goods">
  14. <div class="com-smartform-goods">
  15. <el-card class="edit-card" shadow="never">
  16. <div slot="header" class="clearfix">
  17. <div class="card-title">商品关联智能表单设置<span class="card-sub-title"></span></div>
  18. </div>
  19. <el-form :model="smartGoodForm" size="small" v-if="smartGoodForm">
  20. <div >
  21. <el-form-item label="开启表单关联商品" prop="is_relation">
  22. <el-switch :active-value="1" :inactive-value="0" v-model="smartGoodForm.is_relation"></el-switch>
  23. </el-form-item>
  24. <el-row :gutter="10" v-if="smartGoodForm.is_relation == 1">
  25. <el-form-item label="选择表单">
  26. <el-button type="primary" size="mini" @click="opensmartform">选择表单</el-button>
  27. </el-form-item>
  28. <el-form-item label="已选表单">
  29. <el-row :gutter="3">
  30. <el-col :span="3" >
  31. <form-diy-list v-for="(f,fi) in smartForm" :key="fi" :item="f" :index="fi" ></form-diy-list>
  32. </el-col>
  33. </el-row>
  34. </el-form-item>
  35. </el-row>
  36. </div>
  37. </el-form>
  38. </el-card>
  39. <!-- 弹窗 -->
  40. <el-dialog
  41. title="表单"
  42. :visible.sync="SmartFormdialog"
  43. width="30%"
  44. >
  45. <div>
  46. <el-table :data="smartFormList" stripe v-loading="loading" size="small" style="margin-bottom: 15px;">
  47. <el-table-column width="100px" label="" props="id" >
  48. <template slot-scope="props">
  49. <el-radio-group v-model="radioSelection" @change="handleSelectionChange(props.row)">
  50. <el-radio :label="props.row.id"></el-radio>
  51. </el-radio-group>
  52. </template>
  53. </el-table-column>
  54. <el-table-column prop="id" min-width="50" label="表单ID" align="center"></el-table-column>
  55. <el-table-column prop="title" min-width="50" label="表单名称" align="center"></el-table-column>
  56. </el-table>
  57. <div style="flexcenter">
  58. <el-button type="primary" size="mini" @click="SmartFormdialog = false">保存</el-button>
  59. </div>
  60. </div>
  61. </el-dialog>
  62. </div>
  63. </template>
  64. <script>
  65. Vue.component('com-smartform-goods',{
  66. template: "#com-smartform-goods",
  67. props: {
  68. goods_id: {
  69. type: Number | String,
  70. default: 0
  71. }
  72. },
  73. data() {
  74. return {
  75. SmartFormdialog:false,
  76. loading:false,
  77. radioSelection:false,
  78. smartGoodForm: {
  79. is_relation:1,
  80. multiple_selection:[]
  81. },
  82. smartFormList:[],
  83. smartForm:[]
  84. }
  85. },
  86. watch: {
  87. // form:{
  88. // deep:true,
  89. // immediate: true,
  90. // handler(value){
  91. // this.$emit("select", {Redpack: this.form});
  92. // }
  93. // }
  94. },
  95. mounted: function() {
  96. this.getsmartFormConfig()
  97. this.getSmartFormList()
  98. // if (this.goods_id) this.redpack();
  99. },
  100. methods: {
  101. handleSelectionChange(row){
  102. console.log(row)
  103. this.smartForm = []
  104. this.smartForm.push(row)
  105. console.log('this.smartForm',this.smartForm)
  106. },
  107. opensmartform(){
  108. this.SmartFormdialog = true
  109. },
  110. getsmartFormConfig(){
  111. this.loading = true
  112. request({
  113. params: {
  114. r: 'smart-form/form-goods/info',
  115. goods_id:this.goods_id
  116. },
  117. method: 'get',
  118. data: { }
  119. }).then(res => {
  120. this.loading = false
  121. this.smartGoodForm.is_relation = res.data.data.status
  122. this.smartForm = []
  123. this.smartForm.push(res.data.data.template)
  124. })
  125. },
  126. handle(type){
  127. },
  128. getSmartFormList(){
  129. this.loading = true
  130. request({
  131. params: {
  132. r: 'smart-form/form/index',
  133. },
  134. method: 'get',
  135. data: { }
  136. }).then(res => {
  137. this.loading = false
  138. this.smartFormList.push(...res.data.data.list)
  139. })
  140. }
  141. }
  142. });
  143. </script>